﻿using System;

namespace ProgressTracker.Account.Infrastructure
{
    public interface IPasswordGenerator
    {
        string GenerateNewPassword();
    }

    public class PasswordGenerator : IPasswordGenerator
    {
        private const int ASCIIStartDecimal = 33;
        private const int ASCIIEndDecimal = 126;

        private const int DefaultPasswordLength = 8;
        
        public string GenerateNewPassword()
        {
            var rand = new Random((int)DateTime.Now.Ticks);
            string newPass = "";

            for (int count = 0; count < DefaultPasswordLength; count++)
            {
                newPass += (char)rand.Next(ASCIIStartDecimal, ASCIIEndDecimal);
            }

            return newPass;
        }
    }
}
